package es.ats.codington.festival.utils;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

import es.ats.codington.festival.JSon.JSonAccess;

/**
 * This source code tries to establish a connection to a MySQL server
 * and displays a message concerning the error if connection fails
 *  
 * @author equipo bit
 *
 */
public class FERSDataConnection3 {

	static Connection con ;
	
	/**
	 * This source code tries to establish a connection to a MySQL server
	 * and displays a message concerning the error if connection fails
	 * Following method creates a connection and returns it
	 * @return
	 */
	public static Connection getConnection() {


			 try {
				 JSonAccess json = new JSonAccess();
			
			  
			Class.forName(json.getBDDriver());
			
			//Obtaining a connection using DriverManager class
			con = DriverManager.getConnection(json.getBDUrl(), json.getBDUser(), json.getBDPass());
				 
				 
		 
				
			} catch (ClassNotFoundException e) {
				
				e.printStackTrace();
			} catch (SQLException e) {
				
				e.printStackTrace();
			}
				
		return con;
	}
	
}
